import ijeoma.tween.*;
import ijeoma.easing.*;

static int FPS = 32;

Rect rect;
Tween tween1, tween2, tween3, tween4;
TweenGroup tweenGroup;

void setup() {
    size(400, 400, P3D);

  frameRate(FPS);
  rectMode(CENTER);

  rect = new Rect(this, width/2, height/2, width, height, color(0));

  float duration = 100f;

  tween1 = new Tween(this, "Tween1", rect, "scaleX", 0f, 1f, duration, Tween.FRAMES, 0f, new Quad(), Tween.EASE_IN);
  tween2 = new Tween(this, "Tween2", rect, "scaleY", 1f, 0f, duration, Tween.FRAMES, 0f, new Quad(), Tween.EASE_IN);
  tween3 = new Tween(this, "Tween3", rect, "scaleX", 1f, 0f, duration, Tween.FRAMES, 0f, new Quad(), Tween.EASE_IN);
  tween4 = new Tween(this, "Tween4", rect, "scaleY", 0f, 1f, duration, Tween.FRAMES, 0f, new Quad(), Tween.EASE_IN);

  tweenGroup = new TweenGroup(this, new Object[]{tween1, tween2, tween3, tween4});
  tweenGroup.repeat(Tween.REVERSE);
  tweenGroup.start();
}

void draw() {
  background(255);

  tweenGroup.update();
  
  rect.draw();
}

void tweenStartedEvent(TweenEvent te) {
  println(te);
}

void tweenEndedEvent(TweenEvent te) {
  println(te);
}

void tweenGroupStartedEvent(TweenEvent te) {
  println(te);
}

void tweenGroupEndedEvent(TweenEvent te) {
  println(te);
}





